package com.prototype.tests {
	import com.prototype.view.background.TiledBackground;
	import flash.display.Sprite;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	
	/**
	 * ...
	 * @author Santiago.J.Elizalde
	 */
	public class TextureTest extends Sprite {
		private var bg:TiledBackground;
		
		public function TextureTest() {
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			stage.scaleMode = StageScaleMode.NO_BORDER;
			bg = new TiledBackground();
			addChild(bg);
			bg.y = stage.stageHeight - bg.height;
			
			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
		}
		
		private function onKeyDown(e:KeyboardEvent):void {
			if (e.keyCode == Keyboard.LEFT) {
				bg.moveBy(-4);
			}
			if (e.keyCode == Keyboard.RIGHT) {
				bg.moveBy(4);
			}
			if (e.keyCode == Keyboard.UP) {
				bg.tileScale += 0.05;
				bg.y = stage.stageHeight - bg.height;
			}
			if (e.keyCode == Keyboard.DOWN) {
				bg.tileScale -= 0.05;
				bg.y = stage.stageHeight - bg.height;
			}
		}
		
	}

}